<template>
  <ul class="top-goods-list" v-if="list.length">
    <li v-for="item in list" :key="item.id">
      <RouterLink to="/">
        <img :src="load" alt="" v-ilazy="item.picture"/>

        <!-- v-if v-else -->
        <!--
        <template v-if="list && item.title && item.alt">
          <p class="name">{{ item.title }}</p>
          <p class="desc">{{ item.alt }}</p>
        </template>

        <template v-else>
          <p class="name" :class="{ new: !(list && item.title && item.alt) }">
            {{ item.name }}
          </p>
          <p class="price" :class="{ new: !(list && item.title && item.alt) }">
            &yen;{{ item.price }}
          </p>
        </template>
        -->

        <!-- 短路语法 -->
        <p class="name">{{ item.title || item.name }}</p>
        <p :class="{ desc: item.alt, price: item.price }">
          <span v-if="item.price">&yen;</span> {{ item.alt || item.price }}
        </p>
      </RouterLink>
    </li>
  </ul>

  <ul class="top-goods-list" v-else>
      <li v-for="i in 4" :key="i">
          <p><xtx-skeleton width='306' height='306' backgroundColor='#eee'></xtx-skeleton></p>
          <p style="margin-top:5px"><xtx-skeleton width='306' height='42' backgroundColor='#eee'></xtx-skeleton></p>
          <p style="margin-top:5px"><xtx-skeleton width='306' height='42' backgroundColor='#eee'></xtx-skeleton></p>
      </li>
  </ul>
</template>

<script>
export default {
  props: {
    list: {
      type: Array,
      default: () => []
    }
  }
}
</script>

<style lang='less' scoped>
.top-goods-list {
  display: flex;
  justify-content: space-between;
  height: 426px;
  li {
    width: 306px;
    height: 406px;

    background: #f0f9f4;
    // 激活效果
    transition: all 0.5s;
    &:hover {
      transform: translate3d(0, -6px, 0);
      box-shadow: 0 6px 8px rgba(0, 0, 0, 0.2);
    }
    // end

    img {
      width: 306px;
      height: 306px;
    }
    p {
      font-size: 22px;
      padding-top: 12px;
      text-align: center;
      text-overflow: ellipsis;
      overflow: hidden;
      white-space: nowrap;
    }

    .desc {
      color: #999;
      font-size: 18px;
    }

    .price {
      color: @priceColor;
    }
  }
}
</style>
